package com.lee.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lee.bean.Student;
import com.lee.mapper.StudentMapper;
import com.lee.service.StudentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by dllo on 18/4/16.
 */
@Service
public class StudentServiceImpl implements StudentService {

    @Resource
    private StudentMapper studentMapper;

    @Override
    public PageInfo queryStudentByPage(Integer pageNo, Integer pageSize) {
        pageNo = pageNo == null ? 1 : pageNo;
        pageSize = pageSize == null ? 10 : pageSize;

        //这句话一定写在查询之前
        PageHelper.startPage(pageNo,pageSize);
        List<Student> studentList = studentMapper.selectAllStudent();
        return new PageInfo<Student>(studentList);
    }
}
